package guanqu.beans;


import java.io.Serializable;
import java.sql.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name ="t_SysUser")
public class SysUser implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = -8980713805831699470L;
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="ID")
	private long id;
	@Column(name="USER_ACCOUNT",nullable=false,unique=true)
	private String userAccount;
//	@ManyToOne(targetEntity=SysDepartment.class,optional=true)
//	@JoinTable(
//			name="t_SysUserDepartment",
//			joinColumns =@JoinColumn(name="USER_ID"),
//			inverseJoinColumns =@JoinColumn(name="DEAPRT_ID",nullable=true))
//	private SysDepartment department;
	@Column(name = "USER_NAME",nullable=false,unique=true)
	private String userName;
	@Column(name = "USER_PASSWORD",nullable=false)
	private String userPassword;
	@Column(name = "LAST_LOGIN_IP")
	private String lastLoginIP;
	@Column(name = "LAST_LOGIN_TIME")
	private Date lastLoginTime;
	@Column(name = "ENABLED")
	private Boolean enabled;
	@Column(name="ROLE",nullable=true)
	private String role;
	public SysUser() {
		super();
	}
	
	public long getId() {
		return id;
	}
	
	public void setId(long id) {
		this.id = id;
	}

	public String getUserAccount() {
		return userAccount;
	}

	public void setUserAccount(String userAccount) {
		this.userAccount = userAccount;
	}

//	public SysDepartment getDepartment() {
//		return department;
//	}
//
//	public void setDepartment(SysDepartment department) {
//		this.department = department;
//	}

	public Boolean getEnabled() {
		return enabled;
	}
	public void setEnabled(Boolean enabled) {
		this.enabled = enabled;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

	public String getLastLoginIP() {
		return lastLoginIP;
	}

	public void setLastLoginIP(String lastLoginIP) {
		this.lastLoginIP = lastLoginIP;
	}

	public Date getLastLoginTime() {
		return lastLoginTime;
	}

	public void setLastLoginTime(Date lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	public String getRole() {
		return role;
	}

	public void setRole(String role) {
		this.role = role;
	}
	public String getNativeUserAccount()
	{
		return getUserAccount().substring(2,10);
	}
}
